/**
 * @param {number[]} nums
 * @return {number}
 */
 var firstMissingPositive = function(nums) {
      function turn_obj(Array) {
          var obj = {}
         for(var n = 0;n<Array.length;n++){
             obj[n] ="a";
         }
         console.log();
         for(var m = 0;m<Array.length;m++){
             obj[Array[m]] = Array[m];
             
         }
         console.log(obj);
     }
     var obj = turn_obj(nums);
     for(let i=0;i<nums.length;i++){
        if(obj[i] =="a"){
            break;
        }
     }
     return i;

};
function arr_obj(query) {
    // 如果未传递参数，就赋值为 undefined
    this.query = query || undefined;
    this.params = this.query;
  
    // 默认对象
    var defaultObj = {};
    // 默认数组
    var defaultArr = [];
    // 数组转对象
    this.arrToObj = function(arr) {
      var obj = {}
      for (var i = 0; i < arr.length; i++) {
        // 数组转为对象，对象的键=数组值， 对象的值=数组值
        obj[arr[i]] = arr[i];
        // 如果是数组，就再次调用自身 (this.arrToObj),递归接着循环
        if (Object.prototype.toString.call(arr[i]) == "[object Array]") {
          var deepArray = this.arrToObj(arr[i])
          continue;
        } else {
          defaultObj[i] = "a";  
          defaultObj[arr[i]] = arr[i]
          
        }
      }
      this.params = defaultObj;
    };
  
    // 对象转数组
    this.objToArr = function(obj) {
      var arr = [];
      for (var i in obj) {
        arr.push(obj[i]);
        // 如果是对象，就再次调用自身 (this.ObjToObj)，递归接着循环
        if(Object.prototype.toString.call(obj[i]) == "[object Object]"){
          var deepObject=this.objToArr(obj[i]);
          continue;
        }else{
          defaultArr.push(obj[i])
        }
      }
      this.params = defaultArr;
    };
  
    if (Object.prototype.toString.call(this.query) == "[object Array]") {
      this.arrToObj(this.query);
    } else if (Object.prototype.toString.call(this.query) == "[object Object]") {
      this.objToArr(this.query);
    } else if (Object.prototype.toString.call(this.query) == "[object Undefined]") {
      console.error("没有获取到传递进来的参数", this.params);
      throw "没有获取到传递进来的参数"
    } else {
      console.error("错误的参数:", this.params,
        "错误的参数类型:", Object.prototype.toString.call(this.params));
      throw "传递的参数只能是对象或者数组类型"
    }
    return this.params;
  }
    firstMissingPositive([1,2,0]);
    console.log(firstMissingPositive([1,2,0]));
    
    // console.log(arr_obj([3,2,0]));